package com.preguicoso.client.error;

import com.google.gwt.core.client.GWT;
import com.google.gwt.event.dom.client.ClickEvent;
import com.google.gwt.uibinder.client.UiBinder;
import com.google.gwt.uibinder.client.UiField;
import com.google.gwt.uibinder.client.UiHandler;
import com.google.gwt.user.client.Window;
import com.google.gwt.user.client.ui.Button;
import com.google.gwt.user.client.ui.Composite;
import com.google.gwt.user.client.ui.HasText;
import com.google.gwt.user.client.ui.RootPanel;
import com.google.gwt.user.client.ui.Widget;
import com.google.gwt.user.client.ui.Image;
import com.google.gwt.user.client.ui.InlineLabel;

public class ErrorMsg extends Composite{

	private static ErrorMsgUiBinder uiBinder = GWT
			.create(ErrorMsgUiBinder.class);
	@UiField Image imagem;
	@UiField InlineLabel msg;

	interface ErrorMsgUiBinder extends UiBinder<Widget, ErrorMsg> {
	}

	public ErrorMsg() {
		initWidget(uiBinder.createAndBindUi(this));
	}
	
	public ErrorMsg(String nome, String tipo) {
		initWidget(uiBinder.createAndBindUi(this));
		if(tipo.equals("info")){
			this.setStyleName("info");
			imagem.setUrl("img/info.gif");
		}
		if(tipo.equals("error")){
			this.setStyleName("error");
			imagem.setUrl("img/error.png");
		}
		if(tipo.equals("warn")){
			this.setStyleName("warn");
			imagem.setUrl("img/warn.png");
		}
		
		msg.setText(nome);
		show();
	}

	private void show() {
		RootPanel.get("error").setStyleName("show");
	}
	
	
	
	


}
